// pages/my/bag/suitDetail.js

/* json文件中配置自定义组件，会使onLoad等函数无效;
    已确认：和函数声明方式有关系，需用 myfunc = function(arg) {}形式
 */

import  CommonPage from "../../../common/CommonPage.js"
const app = getApp()
const api = require('../../../api/http.js')
const config = require('../../../../config.js')

class SuitDetailPage extends CommonPage {
  /**
   * 页面的初始数据
   */
  constructor(...args) {
    super(...args)
    super.$init({
      idList: [],
      merchList: [],
      suitMap: {},
      suitId: null,
      height: "0rpx",
      showImage: 'true',
      backImagePath: getApp().globalData.backImagePath,
      titleName: '童年大礼包',
      modalPattern: {},
      modalCancelEvent: "hideModal",
      modalConfirmEvent: "hideModal",
      modalArgs: null,
      nannerTitleColorLeft: "#4D7BFE",
      nannerTitleColorRight: "#000",
    })
  }

  back = function() {
    app.back()
  } 

  initData = function(query, resolve, reject) {
    var suitMap = JSON.parse(query.suitMap)
    var merchs = suitMap.merchs
    this.data.suitId = Number(query.suitId)
    this.data.suitMap = suitMap
    this.data.merchList = merchs
    this.data.titleName = query.name
    this.data.height = app.globalData.titleHeight
    this.$setData(this.data)
     
  }

  $onNavigator(query) {
    console.debug("预加载-礼包详情；参数：",query)
    this.$put("suitdetail-data", this.initData.bind(this), query)
  }
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad = function(query) {
    console.debug("SuitDetail Data:", this.data)
    var dat = this.$take("suitdetail-data")
    if (dat) return
    this.initData(query)
  }
  // //显示自定义对话框
  // showModal = function () {
  //   this.modal.showModal()
  // }
  // //隐藏自定义对话框
  // hideModal = function () {
  //   this.modal.hideModal()
  // }
}

Page(new SuitDetailPage({clazzName: "SuitDetailPage"}))
// Page(new SuitDetailPage())
